package com.dycx.food.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.*;

/**
 * 订单类型
 */
@Getter
@AllArgsConstructor
public enum OrderGoodsStatusEnum {

    WAITING(1, "待制作", "error"),
    PRODUCTION(2, "制作中", "warning"),
    END(3, "已制作", ""),
    COMPLETE(4, "已出餐", "success");

    private final Integer code;
    private final String name;
    private final String style;

    public static OrderGoodsStatusEnum converter(Integer code) {
        return Arrays.stream(values()).filter(en -> en.code.equals(code)).findAny().orElse(WAITING);
    }

    /**
     * 转为列表
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (OrderGoodsStatusEnum item : OrderGoodsStatusEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", item.getCode().toString());
            map.put("name", item.getName());
            list.add(map);
        }
        return list;
    }
}
